<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WeakMap的语法</title>
</head>
<body>
    <div>xiasnn</div>
    <div>xiaxia</div>

    <script>
        // WeakMap的键名只可以是引用类型
        let weakmap = new WeakMap();
        // weakmap.set("sfsf","hfiosdf");   //报错
        weakmap.set([],"hjsadfhs");
        weakmap.set({},"hjsadfhs");

        // dom元素是对象
        let divs = document.querySelectorAll('div');
        divs.forEach(item => {
            weakmap.set(item,item.innerHTML);
        });
        console.log(weakmap);


        // 增删查
        let arr = [];
        let weakmap1 = new WeakMap();
        // 增
        weakmap1.set(arr,"houdunren.com");
        // 删
        weakmap1.delete(arr);
        // 查
        console.log(weakmap1.has(arr));
        console.log(weakmap1);


        // WeakMap不可以使用size,keys(),values(),entries()和for...of...
    </script>
</body>
</html>